package com.zyx.thread1;

public class Client extends Thread{
    private Bank bank;//共享资源（银行账户）
    private int want;//想要取款的金额

    public Client(String name, Bank bank, int want) {
        super(name);
        this.bank = bank;
        this.want = want;
    }

    @Override
    public void run() {
        int money;
        //当取款金额大于0时，为正常取款
        while ((money=this.bank.getMoney(want))>0){
            //System.out.println(this.getName()+"取到钱了");
        }
        //取款结束后，打印提示
        System.out.println("取款结束");
    }

}
